package com.resp;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/Servlet006")
public class Servlet06 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("执行了servlet06....");

        ServletContext servletContext = req.getServletContext();

        //获取文件的MIME类型
        //String mimeType = servletContext.getMimeType("1.jpg");
        //System.out.println(mimeType);//image/jpeg

        //String mimeType = servletContext.getMimeType("haha.mp4");
        //System.out.println(mimeType);//video/mp4

        String mimeType = servletContext.getMimeType("demo.html");
        System.out.println(mimeType);//text/html

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
